package zozopo.warehouse;

import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;
import zozopo.warehouse.operations.GoodsOS;
import zozopo.warehouse.operations.GoodsTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class InsertGoodsInfoAction  extends ActionSupport implements Action,SessionAware{
	
	//传入参数
	private String searchStr = "";
	//分页参数
	private int beginPageNum = 0;
	private int pageSize = 20;
	private int rowNum = 0;
	//传出参数
	private List<GoodsTB> goodsList;
	
	private Map<Object, Object> session;
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	public String execute(){
		
		
		
		
		GoodsOS goodsOS = new GoodsOS();
		//UserOS userOS = new UserOS();
		
		if(searchStr.equals("")){
			goodsList = goodsOS.selectGoods(beginPageNum, pageSize);
			rowNum = goodsOS.getRowNum();
		}else{
			goodsList = goodsOS.selectBySearchStr(searchStr,beginPageNum, pageSize);
			rowNum = goodsOS.getRowNumForSearchStr(searchStr);
		}
		
		
		goodsOS.releaseConnection();
		
		return SUCCESS;

	}
	
	public String getSearchStr() {
		return searchStr;
	}
	public void setSearchStr(String searchStr) throws UnsupportedEncodingException {
		this.searchStr = java.net.URLDecoder.decode(searchStr, "UTF-8");
		this.searchStr = this.searchStr.trim();
	}
	public int getBeginPageNum() {
		return beginPageNum;
	}
	public void setBeginPageNum(int beginPageNum) {
		this.beginPageNum = beginPageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getRowNum() {
		return rowNum;
	}
	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}
	public List<GoodsTB> getGoodsList() {
		return goodsList;
	}
	public void setGoodsList(List<GoodsTB> goodsList) {
		this.goodsList = goodsList;
	}
}
